# import csv
#
# # 假设你有以下列表：
# list1 = ['aASASA,FFG', 'bDDGSGSG.HJG', 'cFHDHFD|DWWQ']
# list2 = [1, 2, 3]
# list3 = ['x', 'y', 'z']
#
# # 打开一个新的CSV文件进行写入：
# with open('output.csv', mode='w', newline='') as file:
#     writer = csv.writer(file)
#     # 写入标题行（如果需要）
#     writer.writerow(['A', 'B', 'C'])
#     # writer.columns = ['List 1', 'List 2', 'List 3']
#     # 使用zip函数将列表按列进行组合，然后写入CSV文件
#     writer.writerows(zip(list1, list2, list3))
# import time
#
# import pandas as pd
#
# # 假设你有两个列表
# list1 = ['a', 'b', 'c', 'd']
# list2 = [1, 2, 3]
# for i in range(len(list1)):
#     num = list(range(1, len(list1) + 1))
#
# # 使用字典将列表转换为pandas的DataFrame
# df = pd.DataFrame({'序号':num,'列名1': list1, '列名2': list2})
#
# # 将DataFrame写入CSV文件
# df.to_csv('output.csv', index=False)
# print('休眠20秒')
# for p in range(20, 0, -1):
#     print(p,' ',end='')
#     time.sleep(1)


import csv

# 假设有三个列表，长度不同
names = ['Alice', 'Bob', 'Charlie']
ages = [25, 30, 35, 40]
countries = ['USA', 'Canada', 'UK']

# 打开CSV文件进行写入操作
with open('output.csv', 'w', newline='') as csvfile:
    writer = csv.writer(csvfile)

    # 写入列名
    writer.writerow(['Name', 'Age', 'Country'])

    # 将每个元素按列写入CSV文件中
    for i in range(max(len(names), len(ages), len(countries))):
        row = []
        if i < len(names):
            row.append(names[i])
        else:
            row.append('')
        if i < len(ages):
            row.append(ages[i])
        else:
            row.append('')
        if i < len(countries):
            row.append(countries[i])
        else:
            row.append('')
        writer.writerow(row)